var OrderView = Backbone.View.extend({

	tagName:'ul',

	className: 'listOrder',
	
	
	collection: new OrderCollection(),
	
	
	render: function () {
			
		$(function(){
			$("ul#orders").empty();
		});	
		
		
		_.each(this.collection.models, function(param) {
			var itemView = new ItemView({model: param, parent: this});
			console.log('Items' + param);
			$(function(){
				$("ul#orders").append(itemView.$el);
			});
							
		}, this);
	},
	
	renderResponse: function (itemsId, itemCollection) {
		for (var i = 0; i < itemsId.length; i++) {
			var record = _.find(itemCollection.models, 
			function(param) {
					return itemsId[i] === param.get('itemId')
			} , this);						
			console.log(record);			
			this.collection.add(record);
		}
		this.render();
	}, 
	
	renderAddItem: function (itemModel) {
		console.log('----------------------------------------------');
		this.collection.add_old(itemModel);
		this.render();
	}
});